package com.heima.freemarker.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.FileInputStream;

public class MinIOTest {

    public static  void main(String[] args)throws Exception {
        //读取本地文件
    FileInputStream fileInputStream = new FileInputStream("E:\\index.html");
    //创建minio客户端
        MinioClient minio = MinioClient.builder()
                .credentials("minio", "minio123")//minio账号密码
                .endpoint("http://192.168.200.130:9000")//minio地址
                .build();
        //上传
        PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                .object("index.html")//上传文件名
                .bucket("man") //桶名称
                .contentType("test/html") //文件类型
                .stream(fileInputStream, fileInputStream.available(), -1).build();
        minio.putObject(putObjectArgs);
        //访问地址
        System.out.println("http://192.168.200.130:9000/man/index.html");
    }
}
